/**
 * 用户列表 add by gsh
 */
$(function() {
	$("#btnAdd").click(function() {
		var index = msgWnd.open({
			title : "添加商户信息",
			skin : 'layui-layer-lan',
			type : 2,
			shade : 0.5,
			area : [ "90%", "90%" ],
			maxmin : true,
			content : '/merchant/add',
			zIndex : layer.zIndex
		});
	});

	$("#chkAll").change(function() {
		var chkStatus = $(this).is(":checked");
		$("[id^=chk]:not(#chkAll)").each(function() {
			this.checked = chkStatus;
		});
	});

});

function getChecked() {
	var map = $("[id^=chk]:not(#chkAll)").map(function() {
		if (this.checked)
			return this.value;
	});
	return map.get();
}

function pass(mid) {
	var index = msgWnd.confirm("确认通过吗?", {
		title : "商户申请审核",
		skin : 'layui-layer-lan',
		btn : [ "确定", "取消" ],
		icon : 1
	}, function() {
		$.ajax({
			type : "POST",
			url : "/merchant/audit/pass/"+mid,
			dataType : "json",
			success : function(msg) {
				if (msg.data.status == 1) {
					msgTools.alert("商户申请审核", "审核成功。", 1000);
					if(typeof(reloadPg)!="undefined")
						reloadPg();
					else
						window.location.href = window.location.href;
				}
			}
		});	
		msgWnd.close(index);
	});	
}

function refuseDlg(mid) {
	var index = msgWnd.open({
		title : "商户申请审核",
		skin : 'layui-layer-lan',
		type : 2,
		shade : 0.5,
		area : [ "510px", "420px" ],
		maxmin : true,
		content : '/merchant/audit/msg/' + mid,
		zIndex : layer.zIndex
	});
}

function edit(id) {
	var index = msgWnd.open({
		title : "修改商户信息",
		skin : 'layui-layer-lan',
		type : 2,
		shade : 0.5,
		area : [ "90%", "90%" ],
		maxmin : true,
		content : '/merchant/edit/' + id,
		zIndex : layer.zIndex
	});
}

function viewMerchantImg(id) {
	var index = msgWnd.open({
		title : "查看商家展示图片",
		skin : 'layui-layer-lan',
		type : 2,
		shade : 0.5,
		area : [ "800px", "520px" ],
		maxmin : true,
		content : '/merchant/images/' + id,
		zIndex : layer.zIndex
	});
}
function viewUser(id) {
	var index = msgWnd.open({
		title : "查看用户信息",
		skin : 'layui-layer-lan',
		type : 2,
		shade : 0.5,
		area : [ "510px", "550px" ],
		maxmin : true,
		content : '/user/view/' + id,
		zIndex : layer.zIndex
	});	
}